
QUnit.module('creta_keyboard', function() {

	QUnit.test('new line', function(assert) {
	
		initial_values();
		first_div.innerText = "Lorem Ipsum";
		first_div.dispatchEvent(new KeyboardEvent('keydown', {
		    code: 'Enter',
		    key: 'Enter',
		    charCode: 13,
		    keyCode: 13,
		    view: window,
		    bubbles: true
		}));

		assert.equal(visual_editor.get_text(), "<div>Lorem Ipsum</div>\n<div></div>");
		
	});
	
	QUnit.test('backspace', function(assert) {
	
		initial_values();
		first_div.innerText = "Lorem Ipsum";
		first_div.dispatchEvent(new KeyboardEvent('keydown', {
		    code: 'Enter',
		    key: 'Enter',
		    charCode: 13,
		    keyCode: 13,
		    view: window,
		    bubbles: true
		}));
		
		let selection = window.getSelection();
		let range = document.createRange();

		range.selectNodeContents(first_div);
		selection.removeAllRanges();
		selection.addRange(range);
		
		first_div.nextSibling.dispatchEvent(new KeyboardEvent('keydown', {
		    code: 'Backspace',
		    key: 'Backspace',
		    charCode: 0,
		    keyCode: 8,
		    view: window,
		    bubbles: true
		}));
		
		assert.equal(visual_editor.get_text(), "<div>Lorem Ipsum</div>");
		
	});

  });

  

